<template>
  <el-container>
    <el-aside width="200px">
      <CompanyMenu></CompanyMenu>
    </el-aside>
    <div>
      <el-table :data="projects" style="width: 100%;margin-left: 10px">
        <el-table-column prop="name" label="项目名称" width="185" />
        <el-table-column prop="details" label="项目详情" width="185" />
        <el-table-column prop="department.name" label="负责部门" width="130" />
        <el-table-column prop="companyUser.userinfo.name" label="负责人" width="160" />
        <el-table-column prop="pubTime" label="发布时间" width="185" />
        <el-table-column prop="startTime" label="开始时间" width="185" />
        <el-table-column prop="estTime" label="预计结束" width="185" />
        <el-table-column label="操作" width="185">
          <template #default="scope">
            <el-button type="text" size="small" @click="editClick(scope.$index,scope.row)" >修改</el-button>
          </template>
        </el-table-column>
      </el-table>
      <edit-project ref="EditProjectDialog"></edit-project>
      <el-pagination background @current-change="currentChange" :total="count" :current-page="pageNum" :page-size="pageSize" layout="prev, pager, next">
      </el-pagination>
    </div>
  </el-container>
</template>


<script>
import CompanyMenu from "@/components/menu/CompanyMenu.vue";
import instanceToken from "@/utlis/tokenIdentify.js";
import Breadcrumb from "@/components/leader/department/Breadcrumb";
import EditProject from "@/components/leader/project/EditProject.vue";
export default {
  name: 'EditProjectView',
  components: {
    CompanyMenu,
    Breadcrumb,
    EditProject
  },
  data() {
    return {
      companyUserId:'',
      companyId:'',

      projects:[],
      project:{},

      count:0,
      pageNum:1,
      pageSize:5,

    };
  },
  created() {
    this.initData();
  },
  methods: {
    initData(){
      instanceToken.get("project/leader/initProject",{params:{
          pageNum:this.pageNum,
          pageSize:this.pageSize,
        }}).then(res => {
        this.projects = res.data.data.list;
        this.count = res.data.data.total;
      })

    },
    currentChange(val){
      this.pageNum = val;
      this.initData();
    },
    editClick(index,row){
      let id = row.id;
      this.$refs.EditProjectDialog.show();
      this.$refs.EditProjectDialog.initdata(id,row);
    }
  },

}
</script>